﻿using Abp.AutoMapper;
using Abp.Collections.Extensions;
using Paas.Core.Sys.Entities;
using Basefr.App.Dtos;
using Basefr.Runtime.Extensions;
using System.Collections.Generic;
using System.Linq;

namespace Paas.App.Interface.Sys.Admin.Dtos
{
    [AutoMap(typeof(User))]
    public class UserDto : DtoBase<long>
    {
        public string UserName { get; set; }
        public string Name { get; set; }

        public string Phone { get; set; }

        public string Email { get; set; }

        public string EmployeeNo { get; set; }

        public string OfficePhone { get; set; }

        public bool IsLeader { get; set; }

        public bool IsActive { get; set; }

        public bool IsPreDefined { get; set; }

        public int OrganizationId { get; set; }
        public List<int> OrganizationIds { get; set; }
        public string OrganizationFullName { get; set; }

        public List<RoleUserDto> Roles { get; set; }

        [AutoMap(typeof(RoleUser))]
        public class RoleUserDto
        {
            public long UserId { get; set; }

            public int RoleId { get; set; }
            public string RoleName { get; set; }
        }

        public string RoleNames => Roles?.Select(r => r.RoleName).JoinAsString("，") ?? "";

        public List<string> Permissions { get; set; }
    }
}

